package com.foreknow.demo7;

public class Y extends X {
    private String school;

    public String getSchool() {
        return school;
    }

    public void setSchool(String school) {
        this.school = school;
    }

    //方法重写(覆盖) : 1. 要有继承关系  2. 子类重写父类的方法(规则:方法的名称、参数、返回值型都相同)
    public void showInfo() {
        System.out.println("姓名: "+ this.getName()+"年龄: "+ this.getAge()+"所在学校: "+this.getSchool());
    }

    public static void main(String[] args) {
        Y y = new Y();
        y.setName("fender");
        y.setAge(20);
        y.setSchool("foreknow");
        y.showInfo();
    }

}
